import java.io.*;
import java.util.*;
public class SimilarValues {
	public static void main(String[] args) {
		ArrayList<String> stringList = new ArrayList<String>();
		Map<String,ArrayList<String>> stringMap = new HashMap<String,ArrayList<String>>();
		
		try{
		File file = new File("RB344.csv");
		//PrintWriter output = new PrintWriter("output.csv");
		Scanner in = new Scanner(file);
		while(in.hasNext())
		{
		String test = in.next();
		String[] test1 = test.split(",");
		String first = test1[0].toLowerCase();
		String second = test1[1];

		ArrayList<String> values = stringMap.get(first);
		if (values==null) {
    		values = new ArrayList<String>();
    		stringMap.put(first, values);
		}
		if(!values.contains(second))
		values.add(second);



		}

		Iterator iter = stringMap.entrySet().iterator();
		while(iter.hasNext())
		{
			Map.Entry mapEntry = (Map.Entry)iter.next();
			ArrayList<String> x = (ArrayList<String>)mapEntry.getValue();
			for(int i = 0; i < x.size(); i++)
			{
			System.out.println(mapEntry.getKey()+" "+x.get(i));
		}
			//System.out.println();
			
			

		}
		
	}catch(FileNotFoundException e)
	{
		e.printStackTrace();
	}
	
}
}